<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <%--<div class="layui-card">--%>
    <%--<div class="layui-form layui-card-header layuiadmin-card-header-auto">--%>
    <%----%>
    <%--<div class="layui-form-item">--%>
    <form name="totalForm" id="totalForm" action="${web_domain}/merchant/cloudstore/${params.id}/details" method="get">

        <%--<div class="layui-inline">--%>
        <%--<label class="layui-form-label">商家名称</label>--%>
        <%--<div class="layui-input-inline">--%>
        <%--<input type="text" name="shopName" placeholder="请输入订单名称" value="<c:if test='${params.shopName !=null}'>${params.shopName}</c:if>" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
        <%--</div>--%>

        <%--<div class="layui-inline">--%>
        <%--<label class="layui-form-label">联系人</label>--%>
        <%--<div class="layui-input-inline">--%>
        <%--<input type="text" name="realName" placeholder="请输入订单名称" value="<c:if test='${params.realName !=null}'>${params.realName}</c:if>" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
        <%--</div>--%>

        <%--<div class="layui-inline">--%>
        <%--<label class="layui-form-label">手机号</label>--%>
        <%--<div class="layui-input-inline">--%>
        <%--<input type="text" name="mobile" placeholder="请输入订单名称" value="<c:if test='${params.mobile !=null}'>${params.mobile}</c:if>" autocomplete="off" class="layui-input">--%>
        <%--</div>--%>
        <%--</div>--%>

        <%--<div class="layui-inline">--%>
        <%--<button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> 搜索</button>--%>
        <%--</div>--%>
    </form>
    <%--</div>--%>
    <%--</div>--%>
    <%----%>
    <%--</div>--%>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <table class="layui-table" lay-size="sm">
                <thead>
                <th style="border-color: black;"><fmt:message key='bh' /></th>
                <th style="border-color: black;"><fmt:message key='sptp' /></th>
                <th style="border-color: black;"><fmt:message key='spmc' /></th>
                <th style="border-color: black;">SKU</th>
                <th style="border-color: black;"><fmt:message key='sl' /></th>
                <th style="border-color: black;"><fmt:message key='cz' /></th>
                </thead>
                <c:forEach items="${page.result}" var="detail">
                    <tr>
                        <td style="border-color: black;">${detail.sku.code}</td>
                        <td style="border-color: black;"><img class="preview" style="width:40px;" src="${store_domain}/uploads/${detail.goods.defaultImage}"/></td>
                        <td style="border-color: black;">${detail.goods.name}</td>
                        <td style="border-color: black;">${detail.sku.skuNames}</td>
                        <td style="border-color: black;">${detail.quantity}</td>
                        <td style="border-color: black;">
                            <a href="javascript:void(0);" data-id="${detail.id}" class="layui-btn layui-btn-normal layui-btn-xs feijin-relevance"><fmt:message key='yjgl' /></a>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>


    layui.use(['form', 'laydate'], function () {

        var form = layui.form;


        //一键关联
        $(".feijin-relevance").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='xzglsp' />'
                , content: '${web_domain}/merchant/cloudstore/chooseGoods'
                , maxmin: true
                , area: ['80%', '90%']
                , btn: ['<fmt:message key='qd' />', '<fmt:message key='qx' />']
                , yes: function (index, layero) {
                    var ids = [];
                    layero.find('iframe').contents().find(".feijin-check:checkbox:checked").each(function (index, item) {
                        var id = $(item).val();
                        ids.push(id);
                    });

                    $.ajax({
                        url: "${web_domain}/merchant/cloudstore/relevanceGoodses",
                        type: "post",
                        dataType: "json",
                        data: {
                            "id" : id,
                            "ids": ids.join("-")
                        },
                        success: function (result) {
                            if (result.status) {
                                layer.msg("<fmt:message key='glwc' />");
                                layer.closeAll();
                            }
                        }
                    });

                }
            });
        });


    });

</script>
</body>
</fmt:bundle>
</html>
